package kr.hkit.PowerJava.chapter10;

import java.util.Arrays;
import java.util.Random;

public class LottoGenerater {
	private int[] arr;
	private static final int SIZE = 6;
	private Random rnd;

	public LottoGenerater() {
		arr = new int[LottoGenerater.SIZE];
		rnd = new Random();
	}

	public void getLottoNum() {
		int num = -1;
		for (int i = 0; i < arr.length; i++) {
			num = getNum();
			if (isFind(num)) {
				// num = getNum();
				i--;
			} else {
				arr[i] = num;
			}
		}
	}

	
	public int getNum() {
		return rnd.nextInt(45) + 1;
	}

	public boolean isFind(int searchNum) {
		boolean isEquals = false;
		for (int i = 0; i < arr.length; i++) {
			if (searchNum == arr[i]) {
				isEquals = true;
				break;
			}
		}
		System.out.println(isEquals);
		return isEquals;

	}

	@Override
	public String toString() {
		return Arrays.toString(arr);
	}

	public static void main(String[] args) {
		LottoGenerater lo = new LottoGenerater();
		System.out.println(lo);
		lo.getLottoNum();
		System.out.println(lo);
		String result = lo.isFind(30) ? "Find" : "Not Found";
		System.out.println(result);
	}
}
